# emqx发布/订阅

import paho.mqtt.client as mqtt

# 发布
def on_connect(client, userdata, flags, rc):
    print("Connected with result code: " + str(rc))


client = mqtt.Client()
client.on_connect = on_connect
client.connect('127.0.0.1', 1883, 600) # 600为keepalive的时间间隔
client.publish('测试111', payload='amazing', qos=0)